<!DOCTYPE html>
<html>

<head>
    <title>ajax发送钉钉消息</title>
    <script src="../jquery-3.3.1.min.js"></script>
    <script>
        $(function() {
            console.log("=== start ===");
            $.ajax({
                url: 'https://oapi.dingtalk.com/robot/send' + '?access_token=604d86002b4a8cb4a4a34368818de87f108a033c2cc20ae183a2bc49d07ec7c9',
                type: "get",
                processData: false,
                beforeSend: function(xhr) {
                    xhr.setRequestHeader('Content-Type', 'application/jsonp;charset=utf-8');
                },
                async: true,
                crossDomain: true,
                xhrFields: {
                    withCredentials: false
                },
                data: JSON.stringify({
                    "msgtype": "text",
                    "text": {
                        "content": ",测试"
                    }
                }),
                success: function(res) {
                    console.log("=== success ===");
                    console.log(res);
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        });
        console.log("=== end ===");
    </script>
</head>

<body>
    <h1>钉钉机器人消息发送中。。。</h1>
</body>

</html>